package com.sgb.kjwl.repository.impl;

import com.sgb.kjwl.model.api.ApiSource;
import com.sgb.kjwl.model.api.PreferenceSource;
import com.swgk.core.view.entity.MenuEntity;
import com.sgb.kjwl.repository.CategoryRepertory;
import com.swgk.core.base.api.BaseApiSource;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.base.model.preference.BasePreferenceSource;

import java.util.List;

import io.reactivex.Observable;

public class CategoryRepertoryImpl extends BaseRepertoryImpl implements CategoryRepertory {
    private ApiSource apiSource;
    private PreferenceSource preferenceSource;

    public CategoryRepertoryImpl(BaseApiSource apiSource, BasePreferenceSource preferenceSource) {
        super(apiSource, preferenceSource);
        this.apiSource = (ApiSource) apiSource;
        this.preferenceSource = (PreferenceSource) preferenceSource;
    }

    @Override
    public Observable<BaseEntity<List<MenuEntity<MenuEntity<MenuEntity>>>>> getCategoryMenu(String areaCode) {
        return apiSource.getCategoryMenu(areaCode).compose(this.<BaseEntity<List<MenuEntity<MenuEntity<MenuEntity>>>>>rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<List<MenuEntity<MenuEntity>>>> getsecondCategory(String id,String areaCode) {
        return apiSource.getsecondCategory(id,areaCode).compose(this.<BaseEntity<List<MenuEntity<MenuEntity>>>>rxSchedulerHelper());
    }

    @Override
    public Observable<BaseEntity<List<MenuEntity<MenuEntity<MenuEntity>>>>> getCategoryData(String areaCode) {
        return apiSource.getCategoryData(areaCode).compose(rxSchedulerHelper());
    }
}
